<HTML xmlns:z>
  
 
<HEAD>
  <TITLE>日志编辑</TITLE>
  <META HTTP-EQUIV="pragma" CONTENT="no-cache">
  <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" 	src="../../js/jquery.pack.js"></script>
	<script type="text/javascript"  src="../../js/riaframework.js"></script>
	<script type="text/javascript"  src="../../js/Calendar.js"></script>
    <link href="../../css/table_cssCn.css" rel="stylesheet" type="text/css">
    <link href="../../css/cssCn.css" rel="stylesheet" type="text/css">
</HEAD>
 <script type="text/javascript">
  function ShowTable(imgCtrl)
        {
              var ImgPlusScr ="../../images/icon_expandall.gif"	;      	// pic Plus  +
              var ImgMinusScr ="../../images/icon_collapseall.gif"	;	    // pic Minus - 
            
              var tableCtrl = document.getElementById("zteTable_ssb");
    	        
    		 	    if(imgCtrl.src.indexOf("icon_expandall") != -1)
    		 	    {
    		 	        tableCtrl.style.display ="";
    		 	        imgCtrl.src = ImgMinusScr ;
    		      }
    		      else
    		      {
    		          tableCtrl.style.display ="none";
    		          imgCtrl.src = ImgPlusScr ;		 
    		      }
    		  }
 /////////////////////////////////////////////////////////////
 var timerId = "";
 var timerInfo ={};
  function  searchData()
  {    
     var hrefs = document.location.href.split("?");
     timerId = hrefs[1];
     callUrl('timerFacade/getTimerById.ssm', timerId ,'timerInfo','true');  	
  	 var timer = timerInfo.rtnValue;
  	 document.getElementById('timerName').value=timer.name;
  	 document.getElementById('timerPurpose').value=timer.purpose;
  	 var triggers = timer.trigers;
  	 if(triggers!=null && triggers != "")
  	 {
  	     setTableValue("zteTable",triggers);
  	 }
  }
  addOnloadEvent(searchData);
 ////////////////////////////////////////////////////////////////////// 
 var saveflag ={};
 var Info ={};
 var data = {};
 function toSave(tib)
 {
     var hrefs = document.location.href.split("?");
    data = getTable_objTrs(tib);
    //alert(data.toJSONString());
    if(data != false)
    {
        var no = document.getElementById('timerName');
        var po = document.getElementById('timerPurpose');
        var rownum = document.getElementById('zteTable_ssb').rows.length;
        
        var hour   = document.getElementsByName("hour");
        var minute = document.getElementsByName("minute");
        var second = document.getElementsByName("second");
        
        for(var i = 1; i < rownum; i++)
        {
           var oinput = document.getElementById('ftime'+i);
           var hourvalue   = hour[i].value;
           var minutevalue = minute[i].value;
           var secondvalue = second[i].value;
           
           if(oinput.value == '' || oinput.value == null)
           {
           		alert("首次运行时间不能为空!");
           		oinput.focus();
           		return false;
           }
           if(hourvalue == '' || hourvalue == null)
           {
           		alert("首次运行时间时、分、秒不能为空!");
           		hour[i].focus();
           		return false;
           }
           if(minutevalue == '' || minutevalue == null)
           {
           		alert("首次运行时间时、分、秒不能为空!");
           		minute[i].focus();
           		return false;
           }
           if(secondvalue == '' || secondvalue == null)
           {
           		alert("首次运行时间时、分、秒不能为空!");
           		second[i].focus();
           		return false;
           }
           
           if(hourvalue >= 24 || hourvalue < 0)
           {
           		alert("首次运行时间时应为零或小于24的正整数!");
           		hour[i].focus();
           		return false;
           }
           if(minutevalue >= 60 || minutevalue < 0)
           {
           		alert("首次运行时间分应为零或小于60的正整数!");
           		minute[i].focus();
           		return false;
           }
           if(secondvalue >= 60 || secondvalue < 0)
           {
           		alert("首次运行时间秒应为零或小于60的正整数!");
           		second[i].focus();
           		return false;
           }
        }
        if(no.value == '')
        {
        	alert("定时器名称不能为空!");
        	no.focus();
        	return  false;
        }
        
               
	    Info.name = no.value;
	    Info.purpose = po.value;
	
	    Info.id =  timerId;
	    var ccc = "["+Info+","+data+"]";
	   
	     callUrl('timerFacade/updateTimer.ssm', '[Info,data]' ,'saveflag','true');
	     
	     if(saveflag.rtnValue == true)
	     {
	        alert("保存成功!");
	     }
	     else{
	        alert("保存失败! 详细信息请查看系统日志!");
	     }
    }
 }
 var fff = {};
 function deleteOne(a)
 {
    var hrefs = document.location.href.split("?");
    var td = a.parentNode;
    var inputo = td.getElementsByTagName('input');
    var id = inputo[0].value;

    var con = timerId+","+id;    

   var tr = td.parentNode;
   var model= getTableById("zteTable");
   var flag = deleteOneRow("zteTable",tr);

    if(flag == true && id != '')
    {  
       callUrl('timerFacade/removeOneTrigger.ssm', con ,'fff','true');
       if(fff.rtnValue == true){
          alert("删除成功!");
       }else{
          alert("删除失败!");
       }
       

    }

 }

function runtimes(s)
{
    var regu1 = "^[1-9][0-9]*$";
	var regu2 = "^-[1]{1}$";
	var re1 = new RegExp(regu1);
	var re2 = new RegExp(regu2);

	if (s.search(re1) != -1 || s.search(re2) != -1) {
	  
	   return true;
	} else {
	  alert("执行次数为正整数，无限次用-1表示");
	   return false;
	   
	}
}
  </script>
  
<BODY >
	
<z:binds>
    <z:bind ctrl="timername"  ref="obj1.name" />
	<z:bind ctrl="timerpurpose"  ref="obj1.purpose" />
	<z:bind ctrl="zteTable"  ref="listArr" />	
</z:binds>
<z:service id='updateTimer' method='post' url='timerFacade/updateTimer.ssm'>
	<z:request onRequest=''  offRequest=''/>
	<z:response rtn=''  onResponse='' offResponse='' onerror=''/>
</z:service>
<DIV id=overDiv style="POSITION: absolute; Z-INDEX: 1"></DIV>
 	<table width="98%"  border="0" cellpadding="0" cellspacing="1">
  <tr>
    <td><div class="div_subtitle">当前位置：系统管理<span class="arrow_subtitle">&gt;</span>应用配置<span class="arrow_subtitle">&gt;</span>定时器配置</div> </td>
  </tr>
</table>
<TABLE align=center cellPadding=0 cellSpacing=0 id=tb_content>
  <TBODY>
    <TR>
      <TD vAlign=top>
<TABLE align=center class=tb_input cellPadding=0 cellSpacing=0 id=tb_content>
  <TBODY>
    <TR>
      <TD vAlign=top>        
          <CENTER>
           <TABLE 
            width="100%" border="0" cellpadding="0" cellSpacing=1 class=tb_input>
        <TBODY>
          <TR>
            <TD colSpan=2><img src="../../images/icon_note.gif" width="18" height="18">定时器查看</TD>
          </TR>
          <TR>
            <TD width="11%" noWrap class="td_title">名称<font color="#FF0000"><span class="style1">*</span></font></TD>
            <TD ><input type="text" id="timerName" value=""/></TD>
          </TR>
          <TR align="right">
            <TD width="11%" align="left" class="td_title">描述</TD>
            <TD align="left" noWrap><textarea name="textarea" id="timerPurpose" cols="50"></textarea></TD>
          </TR>
        </TBODY>
      </TABLE>
          </CENTER>
     </TD>
    </TR>
    <tr>		
	    <td>
	   
		<z:table id='zteTable' cellspacing="1" style='width:100%; FLOAT:right;display:none;'
		title='<img src="../../images/icon_collapseall.gif" name="Img1" width="16" height="16" 
                 class="icon" id="Img1"  onclick="ShowTable(this);">触发器列表' turnpage='false' editable="true">				
				
				<z:column id=col2 width="10%" caption="执行次数<FONT color=#ff0000>*</FONT>" prop="times" validate="runtimes">
				  <input type="text" name="执行次数" style="width:60px" value=""   nullable="no"/>
				</z:column>
				<z:column id=col2  width="15%" caption="时间间隔类型<FONT color=#ff0000>*</FONT>" prop="trigertype">
				<select style="WIDTH: 100px"  size=1 name=select13 pixedwidth="50">
                <option value="1">秒</option>
                <option value="2">分钟</option>
                <option value="3">小时</option>
                <option value="4">天</option>
                <option value="5">星期</option>
                <option value="6">月</option>
                </select>
				</z:column>				
			    <z:column id=col2  width="15%" caption="时间间隔<FONT color=#ff0000>*</FONT>" prop="span" datatype="posiint">
			    <input type="text" name="时间间隔" style="width:100px" value=""   nullable="no"/>
			    </z:column>
			    <z:column id=col2  width="15%" caption="首次运行时间<FONT color=#ff0000>*</FONT>"  prop="firstruntime" datatype="date">
			      <z:Calendar  id='test1' target='ftime' value='' imgurl='../../images/calendar.gif'/>			      
			    </z:column>	
			    <z:column id=col2  width="15%" caption="时:分:秒">			    
			    <INPUT style="WIDTH: 25px" size=10 name="hour"  prop="hour" value="">
			    <FONT face=宋体>： </FONT>
			    <INPUT style="WIDTH: 25px" size=10 name="minute"  prop="minute" value="">
			    <FONT face=宋体>： </FONT>
			    <INPUT style="WIDTH: 25px" size=10 name="second" prop="second" value="">			   
			    </z:column>		   	 
			    <z:column id=col5  width="15%" caption="是否启用" prop="enabled">
			     <select name="">
			        <option value="是">是</option>
			        <option value="否">否</option>
			     </select>
			    </z:column>
			    <z:column id=col5  width="10%" caption="操作" prop="id">
			      <input type="hidden" prop="id" value=""/>
			      <a href='#' width='16' height='16' onclick="deleteOne(this)" >删除</a>
			    </z:column>		    
			</z:table>
		  </td>
		</tr>
		<tr>
		<td>
       <table>
		<tr align="right">
		<td width="98%">
		<input name="Submit" type="button" class="button" onClick="toSave('zteTable')"   value="保存">
        </td>
		<td width="2%">
        <input name="Submit" type="button" class="button" onClick="javascript:history.go(-1);"   value="取消">
         </td>
        </tr>
        </table>
        </td>    
      </tr>
  </TBODY>
</TABLE>   
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>